home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows 95 with MFC / Programming Windows 95 with MFC (Microsoft Programming Series)(097-0001465)(1996).iso / CODE / Chap09 / Paint7 / Paint7.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  1.8 KB  |  71 lines

  1. //***********************************************************************
  2. //
  3. //  Paint7.cpp
  4. //
  5. //***********************************************************************
  6.  
  7. #include <afxwin.h>
  8. #include "Resource.h"
  9. #include "CLine.h"
  10. #include "Paint7.h"
  11. #include "MainFrame.h"
  12. #include "Paint7Doc.h"
  13. #include "Paint7View.h"
  14. #include "AboutDlg.h"
  15.  
  16. CPaintApp myApp;
  17.  
  18. BEGIN_MESSAGE_MAP (CPaintApp, CWinApp)
  19.     ON_COMMAND (ID_FILE_NEW, CWinApp::OnFileNew)
  20.     ON_COMMAND (ID_FILE_OPEN, CWinApp::OnFileOpen)
  21.     ON_COMMAND (ID_APP_ABOUT, OnAppAbout)
  22. END_MESSAGE_MAP ()
  23.  
  24. BOOL CPaintApp::InitInstance ()
  25. {
  26.     SetRegistryKey ("Programming Windows 95 with MFC");
  27.     LoadStdProfileSettings ();
  28.  
  29.     CMultiDocTemplate* pDocTemplate;
  30.     pDocTemplate = new CMultiDocTemplate (
  31.         IDR_CHILDFRAME,
  32.         RUNTIME_CLASS (CPaintDoc),
  33.         RUNTIME_CLASS (CMDIChildWnd),
  34.         RUNTIME_CLASS (CPaintView));
  35.  
  36.     // Convert items in the Color menu to MF_OWNERDRAW
  37.     if (pDocTemplate->m_hMenuShared != NULL) {
  38.         CMenu* pMenu = CMenu::FromHandle (pDocTemplate->m_hMenuShared);
  39.         for (int i=0; i<8; i++)
  40.             pMenu->ModifyMenu (ID_COLOR_BLACK + i,
  41.                 MF_BYCOMMAND | MF_OWNERDRAW, ID_COLOR_BLACK + i);
  42.     }
  43.  
  44.     AddDocTemplate (pDocTemplate);
  45.  
  46.     CMainFrame* pMainFrame = new CMainFrame;
  47.     if (!pMainFrame->LoadFrame (IDR_MAINFRAME))
  48.         return FALSE;
  49.     m_pMainWnd = pMainFrame;
  50.  
  51.     EnableShellOpen ();
  52.     RegisterShellFileTypes (TRUE);
  53.     m_pMainWnd->DragAcceptFiles ();
  54.  
  55.     CCommandLineInfo cmdInfo;
  56.     ParseCommandLine (cmdInfo);
  57.  
  58.     if (!ProcessShellCommand (cmdInfo))
  59.         return FALSE;
  60.  
  61.     pMainFrame->ShowWindow (m_nCmdShow);
  62.     pMainFrame->UpdateWindow ();
  63.     return TRUE;
  64. }
  65.  
  66. void CPaintApp::OnAppAbout ()
  67. {
  68.     CAboutDialog dlg;
  69.     dlg.DoModal ();
  70. }
  71.